Pre-translated files used in a virtual machine

ABSTRACT

A method and apparatus for speeding the startup of applications by making available a pre-translated class file to the class loaders. The Java virtual machine (JVM) starts faster if application class loaders can use the pre-translated class files or internal representations instead of fetching classes from Java archive files or system directories. JVM understands java executable format and can start faster by using them without the user application class loaders having to know the complexities of executable files. The Java archive file format is modified to allow the pre-translated class files to be stored in the Java archive file such that the class loaders are able to process the modified Java archive file without requiring any change to the class loader.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates generally to an improved data processingsystem, and in particular to a method and apparatus for executingprogramming languages. Still more particularly, the present inventionrelates to a computer implemented method, apparatus, and computer usableprogram code for processing files in a virtual machine.

2. Description of the Related Art

Computer developers have made a number of different computermicroprocessors suited to particular sorts of problems. Machineinstructions, are, in a sense, the language for a particular processingunit architecture. Some microprocessors execute complex instructionsets, while others execute reduced instruction sets.

The instructions are usually difficult for a human being to read andunderstand, let alone write as a program. Consequently, higher-orderlanguages have been conceived that mimic aspects of human languages suchas English. Such languages, including Java™, permit rapid development ofuseful programs, though the resultant code is not immediately executableon a microprocessor. Java is a trademark of Sun Microsystems,Incorporated. In order for such higher-order codes or programs to beused by a microprocessor, the programs must be interpreted and compiledinto a machine language that is suited for the particular processorarchitecture.

Java programs are architecture independent in the sense that allmicroprocessors that have a Java Virtual Machine (JVM) are able tocompile such programs to the machine language of the microprocessor. Thecompiling step may introduce a delay in executing a program, however,this is the cost of making a program independent of the architecture.

Developers have wanted a more rapid way to execute Java programs. Javaprograms are often packaged as a bundle of class files. Each class fileprovides instructions to perform a particular function of a program.However, in order to perform each function, as mentioned above, a Javavirtual machine (JVM) must compile the function into machineinstructions and then execute the compiled machine instructions. Itwould be advantageous to have such compiled machine instructionsavailable at the outset of executing a program. Compiled machineinstructions are among pre-translated versions of the high-levellanguage. Consequently, pre-translated files might be faster to performif such compiled machine instructions were accessible to a Java virtualmachine without compilation.

SUMMARY OF THE INVENTION

The aspects of the present invention provide a computer implementedmethod and computer program product for processing files in a virtualmachine. A virtual machine receives a file loaded by a class loader forthe virtual machine. The virtual machine determines if the file containsa distinctive pattern. The distinctive pattern indicates a set of valuesand a set of modified class data. If it is determined that the filecontains the distinctive pattern, the virtual machine obtains access tothe set of modified class data for an executable class resource.

BRIEF DESCRIPTION OF THE DRAWINGS

The novel features believed characteristic of the invention are setforth in the appended claims. The invention itself, however, as well asa preferred mode of use, further objectives and advantages thereof, willbest be understood by reference to the following detailed description ofan illustrative embodiment when read in conjunction with theaccompanying drawings, wherein:

FIG. 1 shows a block diagram of a data processing system in accordancewith an illustrative embodiment of the present invention;

FIG. 2 shows a block diagram of software components in accordance withan illustrative embodiment of the present invention;

FIG. 3 shows a block diagram of a Java virtual machine (JVM) inaccordance with an illustrative embodiment of the present invention;

FIG. 4 shows a spectrum of abstract code representations in accordancewith an illustrative embodiment of the present invention;

FIG. 5 shows a Java archive file as commonly made and used in accordancewith an illustrative embodiment of the present invention;

FIG. 6 shows a first embodiment of Java archive file in accordance withan illustrative embodiment of the present invention;

FIG. 7 shows a second embodiment Java archive file in accordance with anillustrative embodiment of the present invention;

FIG. 8 shows a detailed collection of parts to a Java archive file inaccordance with an illustrative embodiment of the present invention;

FIG. 9 shows a Java executable class resource that is referenced inaccordance with an illustrative embodiment of the present invention;

FIG. 10 shows a flowchart of a class loading process in accordance withan illustrative embodiment of the present invention;

FIG. 11 shows a flowchart of a virtual machine loading modified classdata in accordance with an illustrative embodiment of the presentinvention; and

FIG. 12 shows a flowchart of a virtual machine translating aspects of aclass file in accordance with an illustrative embodiment of the presentinvention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

With reference now to FIG. 1, a block diagram of a data processingsystem is shown in which embodiments of the present invention may beimplemented. In the depicted example, data processing system 100 employsa hub architecture including north bridge and memory controller hub(MCH) 108 and south bridge and input/output (I/O) controller hub (ICH)110. Processing unit 102, main memory 104, and graphics processor 118connect to north bridge and memory controller hub 108. Graphicsprocessor 118 may connect to north bridge and memory controller hub 108through an accelerated graphics port (AGP).

In the depicted example, local area network (LAN) adapter 112, audioadapter 116, keyboard and mouse adapter 120, modem 122, read only memory(ROM) 124, hard disk drive (HDD) 126, CD-ROM drive 130, universal serialbus (USB) ports and other communications ports 132, and PCI/PCIe devices134 connect to south bridge and I/O controller hub 110 through bus 138.PCI/PCIe devices may include, for example, Ethernet adapters, add-incards, and PC cards for notebook computers. PCI uses a card buscontroller, while PCIe does not. ROM 124 may be, for example, a flashbinary input/output system (BIOS).

Hard disk drive 126 and CD-ROM drive 130 connect to south bridge and I/Ocontroller hub 110 through bus 140. Hard disk drive 126 and CD-ROM drive130 may use, for example, an integrated drive electronics (IDE) orserial advanced technology attachment (SATA) interface. Super I/O (SIO)device 136 may connect to south bridge and I/O controller hub 110.

With reference now to FIG. 2, a block diagram illustrates therelationship of software components operating within a computer systemthat may implement the present invention. Java-based system 200 containsplatform specific operating system 202 that provides hardware and systemsupport to software executing on a specific hardware platform. Javavirtual machine (JVM) 204 is one software application that may executein conjunction with the operating system. Java is a trademark of SunMicrosystems, Incorporated. Java virtual machine 204 provides a Javarun-time environment with the ability to execute Java application orapplet 206, which is a program, servlet, or software componentdevelopers may write in the Java programming language. Java virtualmachine 204 may operate in computer systems similar to data processingsystem 100 of FIG. 1. Nevertheless, developers of a Java virtual machinein accordance with an illustrative embodiment of the present inventionmay implement Java virtual machine 204 on a so-called Java chip,Java-on-silicon, or Java processor with an embedded picoJava core.

At the center of a Java run-time environment is the Java virtualmachine, which supports all aspects of Java's environment, includingJava's architecture, security features, mobility across networks, andplatform independence.

The Java virtual machine is a virtual computer, that is, a computer thatdevelopers specify in the abstract. The specification of the Javavirtual machine defines certain features that every Java virtual machineimplements, with some range of design choices that may depend upon theplatform on which the developers design the Java virtual machine toexecute. For example, all Java virtual machines execute Java bytecodesand may use a range of techniques to execute the instructionsrepresented by the bytecodes. A developer may implement the Java virtualmachine completely in software or partially in hardware. Thisflexibility allows the developers to design different Java virtualmachines for systems ranging from mainframe computers to PDAs and othermicro devices.

The Java virtual machine may also be the name of a virtual computercomponent that actually executes Java programs. The Java virtual machineand not the central processor directly runs Java programs. For example,the processor is processing unit 102 of FIG. 1. The Java virtual machineallows Java programs to execute on a different platform as opposed toonly the one platform for which the developer compiled the code.Developers may compile Java programs for the Java virtual machine. Inthis manner, Java is able to support applications for many types of dataprocessing systems, which may contain a variety of central processingunits and operating systems architectures. To enable a Java applicationto execute on different types of data processing systems, a compilertypically generates an architecture-neutral file format—the compiledcode can execute on many processors, given the presence of the Javarun-time system. The Java compiler generates bytecode instructions thatare nonspecific to a particular computer architecture. A bytecode is amachine independent code that the Java compiler generates and the JavaInterpreter executes. A Java interpreter is part of the Java virtualmachine that alternately decodes and interprets a bytecode or bytecodes.The compiler generates these bytecode instructions so that they are easyfor the interpreter on any computer to interpret and translate on thefly into native machine code. A just-in-time compiler may translate thebytecodes into native code in a process sometimes called just-in-timecompiling (jitting) a method. Embodiments of the present invention mayskip steps that are normally performed just prior to just-in-timecompiling. Embodiments of the present inventions skip when theembodiments discover a pre-translated file.

One type of software-based execution engine is a just-in-time compiler.With this type of execution, the compiler compiles the bytecodes of amethod to native machine code when the application successfully fulfillssome type of criteria for jitting a method. The Java virtual machinethen caches the native machine code for the method and reuses the codeupon the next invocation of the method. Developers may also implementthe execution engine in hardware and by embedding the execution engineon a chip so that the execution engine may execute the Java bytecodesnatively. Java virtual machines usually interpret bytecodes, but Javavirtual machines may also use other techniques, such as just-in-timecompiling mentioned above, to execute bytecodes.

With reference now to FIG. 3, this figure depicts a block diagram of aJava virtual machine in accordance with a preferred embodiment of thepresent invention. Java virtual machine 300 includes class loader 302,which is a mechanism for loading types, such as classes and interfaces,given fully qualified names. Classes may be located in a Java archivefile (JAR), for example, Java archive file 301. Java virtual machine 300also contains runtime data areas 304, execution engine 306, nativemethod interface 308, and memory management 310. Execution engine 306 isa mechanism for executing instructions contained in the methods ofclasses loaded by class loader 302. Java interpreter 312 or just-in-timecompiler 314 are examples of the execution engine 306. Native methodinterface 308 allows access to resources in the underlying operatingsystem. Java native interface (JNI) is an example of native methodinterface 308. Runtime data areas 304 contain native method stacks 316,Java stacks 318, PC registers 320, method area 322, and heap 324. Thesedifferent data areas represent the organization of memory needed by Javavirtual machine 300 to execute a program.

Java stacks 318 store the state of Java method invocations. When theJava virtual machine launches a new thread, the Java virtual machinecreates a new Java stack for the thread. In these examples, the Javavirtual machine performs only two operations directly on Java stacks:the Java virtual machine pushes and pops frames. A thread's Java stackstores the state of Java method invocations for the thread. The state ofa Java method invocation includes its local variables, the parameterswith which a thread invoked the method, an associated return value, ifany, and intermediate calculations. Java stacks comprise stack frames. Astack frame contains the state of a single Java method invocation. Whena thread invokes a method, the Java virtual machine pushes a new frameonto the Java stack of the thread. When the method completes, the Javavirtual machine pops the frame for that method and discards the frame.The Java virtual machine does not have any registers for holdingintermediate values; any Java instruction that requires or produces anintermediate value uses the stack for holding the intermediate values.In this manner, the developers have suitably designed the Javainstruction set for a variety of platform architectures.

Developers use program counter (PC) registers 320 to indicate the nextinstruction a thread executes. Each instantiated thread gets anassociated PC register and Java stack. If the thread is executing a Javavirtual machine method, the value of the PC register indicates the nextinstruction to execute. If the thread is executing a native method, thenthe contents of the PC register are undefined. Native method stacks 316stores the state of invocations of native methods. Native method stacks,registers, or other implementation dependent memory areas store thestate of native method invocations in an implementation-dependent way.Some Java virtual machine implementations combine the native methodstacks 316 and Java stacks 318.

Method area 322 contains class data while heap 324 contains allinstantiated objects. These examples show the constant pool located inmethod area 322. The Java virtual machine specification strictly definesdata types and operations. Most Java virtual machines establish onemethod area and one heap, and all the threads running inside the Javavirtual machine, such as Java virtual machine 300, share the method areaand the heap. When Java virtual machine 300 loads a class file, the Javavirtual machine parses information about a type from the binary datacontained in the class file. Java virtual machine 300 places this typeof information into the method area. Each time the Java virtual machinecreates a class instance or array, it allocates the memory for the newobject from heap 324. An instance is an object of a particular class. Inprograms written in the Java programming language, an instance of aclass is created using the “new” operator followed by the class name. Aninstance of an executable class is an executable function that is storedto memory or other storage in the form of machine instructions. Aninstance of an executable class includes the instructions plus anyunchanging values used by the function.

In these illustrative examples, modified class data take the form of aset of modified bytecodes and optionally modified metadata. The set ofmodified bytecodes contains one or more modified bytecodes. In thedepicted examples, the set of modified bytecodes and metadata aremodified from a Sun class file. A Sun class file is a class file writtenaccording to the Sun Java specifications, including, for example, theclass format validator, 0xCAFEBABE. Modified class data is class datathat a virtual machine is capable of interpreting. More importantly,modified class data is class data that is tailored to the specificvirtual machine in order to allow more efficient memory management andquicker execution. Such gains are possible in comparison to theparticular virtual machine processing ordinary Sun class files. Avirtual machine is, for example, Java virtual machine 300 of FIG. 3.

Modified class data may be pre-translated, since the data is already ina somewhat optimized form for the particular virtual machine. Modifiedclass data is sometimes called an internal representation. An internalrepresentation may be a static internal representation. A staticinternal representation is merely a set of modified class data and a setof values. The set of values may be one or more values in theseexamples. A dynamic internal representation is an allocation in a memoryto at least one data structure that may vary during operation of thestatic internal representation. The memory may be, for example, mainmemory 104 of FIG. 1.

Thus, a static internal representation may have a dynamic internalrepresentation. In that case, the combined static internalrepresentation and the dynamic internal representation are together alsoa modified class data. A set of values contains one or more values. Inthese examples, the set of values may include a single constant definedfor use in the static internal representation. A value is a number thatis stored without changing during the operation of executable code. Avalue may be for example, a known constant such as pi, which a developermay approximate with 3.14159.

Java virtual machine 300 includes an instruction that allocates memoryspace within the memory for heap 324 but includes no instruction forfreeing that space within the memory. Memory management 310, in thedepicted example, manages memory space within the memory allocated toheap 324. Memory management 310 may include a garbage collector, whichautomatically reclaims memory used by objects that are no longerreferenced. Additionally, a garbage collector also may move objects toreduce heap fragmentation.

FIG. 4 shows an abstract spectrum 400 of program representation inaccordance with an illustrative embodiment of the present invention. Onthe left of the spectrum, are representations that are best suited tohuman use, including Java language. On the right of the spectrum isnative code 411 suited for a microprocessor and often a particularmicroprocessor type. One or more embodiments of the invention store andretrieve pre-translated files. These types of files also referred to asmodified class data. A modified class data is an internal format of aclass file suited to operate on a specific Java virtual machine. A setof modified class data is comprised of a set of modified bytecodes or amodified metadata. The set of modified bytecodes may be one or morebytecodes and the modified metadata may be, for example, modified classdata 401. A set of modified class data also includes files that aremodified class data and a dynamic internal representation 403.

Illustrative embodiments of the present invention include a Java virtualmachine that may flexibly read input files that contain both Javaexecutable resource files and locators that reference Java executableresource files. The illustrative embodiments of the present inventionuse archive files that include class proxy files that have a distinctivepattern to signal to the Java virtual machine that the file is a classproxy file. A distinctive pattern indicates a presence of a set ofmodified class data and a set of values. A class proxy file is a filethat does not actually contain the details of a class file, but rathercontains a locator used to find a class file elsewhere. A Java virtualmachine loads class files and executes the bytecodes within the classfiles. A class loader loads the class files. The class loader loadsclass files from an application and the class files from the Javaapplication programming interfaces (APIs) which an application may need.In particular, the class loader skips a translating step when internalrepresentations are available. The execution engine that executes thebytecodes may vary across platforms and implementations.

FIG. 5 shows a known Java archive file or JAR that is commonly made andused. A Java archive file is an example of an archive file. An archivefile is a collection of files that may be compressed into a common file,for example, a Java archive file. A Java archive file contains classfiles and may include auxiliary resources associated with applets andapplications. Java archive file 500 contains a collection of regularclass files, for example, class file 503. In addition, Java archive file500 includes optional manifest file 505, and zero or more resourcefiles, for example, resource file 507. A class file is a set ofinstructions written in an architecture independent language, such asJava. The class file has a class name. A class name is a name for a filethat includes a suffix commonly used to identify an object class file,for example, “.class” as used for an object class file using the Javalanguage. It will be appreciated that other suffixes may be widelyaccepted by industry to identify class files or other architectureindependent languages. In addition to architecture independent code,class file 503 includes a class format validator. A class formatvalidator is a distinctive pattern adopted by a group of developers todesignate that a file is a class file. The class format validator is ata location in the file, for example, a known offset from the beginningof a file. For example, developers of Java class files, locate the classformat validator, 0xCAFEBABE, at a zero offset from the beginning ofclass file 503.

FIG. 6 shows an example of a Java archive file in accordance with anillustrative embodiment of the present invention. Java archive file 600includes a class proxy file 602, second class proxy file 604, thirdclass proxy file 606, Java executable class resource 650, manifest file660, resource file 670, and second resource file 680. Java executableclass resource 650 may include modified bytecodes known as a Javaexecutable or JXE, as used in the IBM J9 Java Virtual Machine availablefrom International Business Machines Corporation. Java executable classresource 650 contains at least one executable file in these examples. Anexecutable file may contain a set of modified class data. The modifiedclass data may be a static J9 internal representation of a class filethat does not require translation into the J9 internal format. Like theclass file of FIG. 5, Java archive file 600 may include manifest 660 inthe same manner as Java archive file 500 of FIG. 5. In addition, Javaarchive file 600 may include resource file 670 similar to resource file507 in FIG. 5. Executable class resource 650 includes modified classdata. A set of modified class data includes a set of bytecodes modifiedfrom an architecture independent language to be efficiently executableon a particular Java virtual machine hosted on a particulararchitecture.

FIG. 7 shows an example of another Java archive file in accordance withan illustrative embodiment of the present invention. In this otherillustrative embodiment, Java archive file 700 includes first classproxy file 702, second class proxy file 704, and third class proxy file706. Fewer or more than three class proxy files may be included within aJava archive file. Java archive file 700 includes manifest 760, firstresource file 770, and second resource file 780. In this example, thedistinction between FIG. 7 and FIG. 6 is that Java archive file 700 doesnot include executable class resource file, but rather may refer to anexternal executable file. The executable file is external in referenceto the archive of files. Executable files are described in more detailin FIG. 9.

FIG. 8 shows the detailed makeup of a class proxy file in accordancewith an illustrative embodiment of the present invention. Class proxyfile 802 includes distinctive pattern 804 and locator 806. A distinctivepattern is a distinctive pattern in a digital file at a location, forexample, a known offset from the beginning or end of the file. Thedistinctive pattern indicates a presence of a set of values and a set ofmodified class data. The distinctive pattern is a reasonably longpattern of data such that it would be unlikely for another file type tohave the same pattern. By “unlikely”, it is meant that a developer whocreates or instructs a machine to create a file would not use thepattern without an intention that the file be later used by a Javavirtual machine and is either an executable class resource or a classproxy file. An example of a distinctive pattern is0x4A39524F4D434C415353434F4F4B4945. A distinctive pattern may begenerated by a developer using a random number generator for subsequentuse. A locator is a reference to an executable class resource that mayreference an offset into an archive file as the location of theexecutable class resource. Alternatively, the locator may referenceusing, for example, a string, a path to a file that is an executableclass resource.

FIG. 9 shows an executable class resource that may be, for example,executable class resource 650 of FIG. 6 in accordance with anillustrative embodiment of the present invention. In addition,executable class resource 950 may reside externally to a Java archivefile in accordance with an illustrative embodiment of the presentinvention. An executable class resource file is a file that includesexecutable file 954 and distinctive pattern 952. Java executable file954 may have a name that includes a “.class” suffix or other filesuffixes associated with architecture independent language files.Executable class resource file 950 may be stored to a default path,commonly used as a storage space for an object class file on a Javavirtual machine. Distinctive pattern 952 may be, for example,0x4A39524F4D434C415353434F4F4B4945. It is appreciated that otherdistinctive patterns may be used and adopted by a group of developers toindicate that the executable class resource is an executable classresource. Executable file 954 is an archive that contains a set ofmodified class data. The set of modified class data may include one ormore class data. As described above, modified class data includes a setof modified bytecodes and a set of values. The archive may include atable of contents and may employ compression and other methods to managethe size of the archive and organize the contents.

To better access executable file 954, a Java virtual machine may have apath or paths established in a configuration file such that the Javavirtual machine searches among such paths for class files and executableclass resources. To avoid ambiguity when loading and processing suchfiles, a developer may establish executable file 954 with a unique nameas related to other files stored among the paths.

FIG. 10 shows a flowchart of a class loading process in accordance withan illustrative embodiment of the present of invention. An illustrativeembodiment of the present invention performs the steps of FIG. 10. Forexample, a class loader such as class loader 302 of FIG. 3 may performthe steps depicted in FIG. 10. An application may create a class loader.The virtual machine or the application may call the class loader to loada class. The class loader typically starts by searching for a class file(step 1001). The search may include converting all period characters ina class name to the directory separator character of the operatingsystem. For each filename so modified, the class loader appends “.class”to the end of the name. A class file may be located in a directory in afile system according to a configuration file associated with the classloader. In addition, the class file may be in a Java archive file, forexample, Java archive file 500 of FIG. 5.

The class loader determines whether the class file has been found (step1003). A negative determination may result in the class loader reportinga failure (step 1005) with the process terminating thereafter. Apositive determination results in the class loader reading the contentsof the class file into a byte array and passing a reference to the bytearray to a function, for example, defineClass( ) (step 1007) with theprocess terminating thereafter. A Java specified application programminginterface is a program that defines how to create a class from asequence of bytes. This step includes reading individual class proxyfiles, each having a “.class” suffix.

FIG. 11 shows a flowchart of a virtual machine loading asset of modifiedclass data in accordance with an illustrative embodiment of the presentinvention. Function defineClass( ) is operating as a part of a virtualmachine. Virtual machine may be Java virtual machine 204 of FIG. 2.Virtual machine receives a file loaded by class loader, for example,archive file 600 of FIG. 6. Virtual machine determines if a distinctivepattern is present in at least one expected place of each file having aclass name, including the class proxy files (step 1109).

If virtual machine finds no class proxy files, as occurs when step 1109is negative, virtual machine behaves like a conventional class loader.Virtual machine further checks to determine if any files have a classformat validator, for example, 0xCAFEBABE (step 1111). The classvalidator, if 0xCAFEBABE, is known as the magic number for Sun classfiles and indicates that the file contains class files. Sun is atrademark of Sun Microsystems, Incorporated. If any necessary file lacksthe validator, the virtual machine performs step 1105. Otherwise,virtual machine creates an internal representation of the class file asan object in the data processor, for example, data processing system 100of FIG. 1.

The virtual machine may create an internal representation in two steps,as may occur in an IBM J9 Java Virtual Machine. First, the virtualmachine may translate the class file into at least one of modifiedbytecode or modified metadata (step 1119). Second, the virtual machinemay create a dynamic internal representation and establish accessinstructions for later use by virtual machine (step 1121). Dynamicinternal representation type of class is a defined set of datastructures that allocate space for each variable that the instantiatedobject may use, for example, counters, indexes and other variables thatare used to temporarily store information. Such variables are set asidefrom other objects or classes to maintain better data integrity. Javastacks 318 of FIG. 3 are a kind of dynamic internal representation type.It is appreciated that other virtual machines may be built that performtranslating step 1119 and creating step 1121 as one step and stillremain within the scope of the invention.

The virtual machine determines if a set of modified class data is loadedinto the virtual machine (step 1113), in response to a positivedetermination from step 1109. A positive determination from step 1113causes virtual machine to obtain a modified class data representation ofthe class (step 1117). Obtaining includes looking up an offset intomemory to find a beginning part to the modified bytecodes and a set ofvalues, wherein the modified bytecodes and set of values may comprise aninternal representation. Obtaining includes providing a virtual machineaccess to the modified class data representation and the set of values.The virtual machine then creates a dynamic internal representation foruse by the modified class data during operation of modified class data(step 1121). It is appreciated that although the present illustrativeembodiment of the invention obtains a modified class data of the class,other embodiments may obtain other internal representations.

The virtual machine may handle a negative determination at step 1113 intwo or more ways, depending on which form the Java archive file takesamong the exemplary forms shown in FIG. 6 and FIG. 7. Generally, theways can be among the steps performed when the virtual machine locatesand loads a set of modified class data (step 1115).

One mechanism for handling a negative determination at step 1113involves the virtual machine reading a class proxy file, for example,class proxy file 602 of FIG. 6. The Java archive file has a Javaexecutable class resource 650 that includes a modified class data for atleast one class proxy file in Java archive file 600. Class proxy file602 includes a locator that points to an offset within executable classresource 650 or an offset within the archive file. The offset representsthe beginning of a modified class data corresponding to class proxy file602. Thus, the virtual machine or class loader reads the locator fromclass proxy file 602. In addition, virtual machine loads the modifiedclass data by looking up the modified class data based on the locator.Looking up may include opening the class proxy file 602.

A second way at step 1115 to locate a set of modified class datainvolves virtual machine reading a class proxy file, for example, classproxy file 702 of FIG. 7. Java archive file 700 may lack an executableclass resource. Instead, each class proxy file may have a locator thatnames an external file with a file path. The file path, in this case,may include a file name. The file path may be a path that references adirectory within a file system of a data processor, for example dataprocessor 100 of FIG. 1. In the latter case, the virtual machine finds afile that is located on a file system in the file path and uses adefault file name. The file system may be, for example, located on harddisk drive 126 of FIG. 1. Illustrative embodiments of the presentinvention organize such executable file 954 as shown in FIG. 9.

FIG. 12 shows a flowchart of a virtual machine translating aspects of aclass file in accordance with an illustrative embodiment of the presentinvention. Steps shown in this figure show, with specificity, one ormore steps that occur within step 1119 in FIG. 11. Embodiments of thepresent invention perform step 1119 when such embodiments discover thatno pre-translated file exists. For example, a J9 Java virtual machinemay operate better if J9 replaces certain bytecodes of a Sun class file.Thus, virtual machine may modify bytecodes (step 1201). One instancewhere a J9 java virtual machine may modify bytecodes is to replace Sunclass bytecodes associated with a Java language ‘return’, also known asreturn bytecodes. Judging by the context of the ‘return’ bytecodes, theJ9 Java virtual machine will substitute in at least one modifiedbytecode to form a modified class data. Such modified bytecode orbytecodes help the J9 Java virtual machine operate more efficientlywhenever such modified bytecodes are compiled and executed.

Java virtual machine may also modify metadata (step 1203). For example,a virtual machine may compress metadata. More specifically, a class filemay have many strings that include ‘Java.lang.Object’. Such strings, ifstored internally in full form, cause excessive use of memory.Consequently, the J9 Java virtual machine may replace each occurrence of‘Java.lang.Object’ with an offset into memory where a singlerepresentation of ‘Java.lang.Object’ is located. It is appreciated thatmany other forms of data compression and re-organization may beperformed and remain within the scope of this step.

Upon concluding step 1203, virtual machine will have created a modifiedclass data. Operation of the embodiment of the present invention thattakes the affirmative path in FIG. 11 step 1109, provides access tomodified class data that is contained within the file loaded earlier.Therefore, an affirmative path from step 1109 permits skipping thelengthy steps of FIG. 12.

A developer may hand edit, or use an authoring tool to make anexecutable class resource, such as, for example, Java executable classresource 650 of FIG. 6. The authoring tool stores a distinctive patternto a file, such that the file has a class name. The authoring toolstores a modified class data to the file to form the executable classresource. In addition, the authoring tool may place the file in anarchive file, for example, Java archive file 600 of FIG. 6. Placingmeans that the tool may compress the file and add metadata to thearchive file or other data structure to sort and locate the file later.The authoring tool may add a class proxy file, for example, class proxyfile 602 of FIG. 6. Class proxy file 602 has a locator that referencesthe modified class data.

Thus, a virtual machine according to the illustrative embodiments of thepresent invention may shorten a process of processing class files bydetecting the presence of internal representations. Once such internalrepresentations are found, a time consuming step of translating isavoided. Consequently, a user may find a data processing system moreresponsive.

Although a Java virtual machine has been shown in one or moreillustrative embodiments of the present invention, it is appreciatedthat the invention encompasses any kind or class of virtual machine.

The invention can take the form of an entirely hardware embodiment, anentirely software embodiment or an embodiment containing both hardwareand software elements. In a preferred embodiment, a developer wouldimplement the invention in software, which includes, but is not limitedto, firmware, resident software, microcode, etc.

Furthermore, the invention can take the form of a computer programproduct accessible from a computer-usable or computer-readable mediumproviding program code for use by or in connection with a computer orany instruction execution system. For the purposes of this description,a computer-usable or computer readable medium can be any tangibleapparatus that can contain or store the program for use by or inconnection with the instruction execution system, apparatus, or device.

The medium can be an electronic, magnetic, optical, electromagnetic,infrared, or semiconductor system (or apparatus or device). Examples ofa computer-readable medium include a semiconductor or solid statememory, magnetic tape, a removable computer diskette, a random accessmemory (RAM), a read-only memory (ROM), a rigid magnetic disk and anoptical disk. Current examples of optical disks include compactdisk-read only memory (CD-ROM), compact disk-read/write (CD-R/W) andDVD.

A data processing system suitable for storing and/or executing programcode will include at least one processor coupled directly or indirectlyto memory elements through a system bus. The memory elements can includelocal memory employed during actual execution of the program code, bulkstorage, and cache memories. Such memory elements provide temporarystorage of at least some program code in order to reduce the number oftimes code is retrieved from bulk storage during execution.

Input/output or I/O devices (including but not limited to keyboards,displays, pointing devices, etc.) can be coupled to the system eitherdirectly or through intervening I/O controllers.

Network adapters coupled to the system enable the data processing systemto couple to other data processing systems or remote printers or storagedevices through intervening private or public networks. Modems, cablemodems and Ethernet cards are just a few of the currently availabletypes of network adapters.

The inventors present this description of the present invention forpurposes of illustration and description, and do not intend it to beexhaustive or limited to the invention in the form disclosed. Manymodifications and variations will be apparent to those of ordinary skillin the art. The embodiment was chosen and described in order to bestexplain the principles of the invention, the practical application, andto enable others of ordinary skill in the art to understand theinvention for various embodiments with various modifications as aresuited to the particular use contemplated.

1. A computer implemented method for processing files in a virtualmachine in a data processing system that includes a processor, thecomputer implemented method comprising: receiving an archive file, whichdoes not include class files, during a class loading process; searching,by the virtual machine that is being executed by the processor, thearchive file to determine if the archive file contains a particular filethat includes a distinctive pattern, wherein the distinctive patternindicates that the particular file is a class proxy file, wherein theclass proxy file includes a locator that points to a location thatincludes a set of modified class data, and further wherein the set ofmodified class data includes a set of bytecodes that have been modifiedfrom an architected independent language to be executable on theparticular virtual machine hosted on the processor that is a particulararchitecture, and still further wherein the class proxy file does notinclude a class file; and responsive to locating the particular file,the class proxy file, and the locator, providing the virtual machineaccess to the set of modified class data.
 2. The computer implementedmethod of claim 1 further comprising: responsive to a determination thatthe archive file does not contain a distinctive pattern, determining ifthe archive file contains a class format validator indicating a presenceof a particular class file; and responsive to a determination that thearchive file contains the class format validator, translating theparticular class file into a second set of modified class data and asecond set of values.
 3. The computer implemented method of claim 1wherein the set of modified class data comprises a set of modifiedbytecodes and a modified metadata.
 4. The method according to claim 1,further comprising: including, in the archive file, a plurality ofdifferent class proxy files, wherein the plurality of different classproxy files includes the class proxy file; and searching each one of theplurality of different class proxy files to determine whether aparticular distinctive pattern is located in one of the plurality ofdifferent class proxy files.
 5. The method according to claim 1, whereinproviding the virtual machine access to the set of modified class datafurther comprises obtaining the set of modified class data, and furtherwherein the set of modified class data and a set of values is a staticinternal representation.
 6. The method according to claim 5, furthercomprising: creating a dynamic internal representation using the set ofmodified class data is used, wherein translation of class files isskipped during the class loading process.
 7. The method according toclaim 1 wherein the distinctive pattern is a file identifier that isstored in a particular location in the class proxy file.
 8. The methodaccording to claim 1, wherein the locator is a data file name thatidentifies a data file in which the modified class data is stored, andfurther wherein the data file is stored in a file system and is notstored in the archive file.
 9. A computer program product that is storedin a non-transitory computer readable medium, the computer programproduct comprising: computer usable program code for processing files ina virtual machine; computer usable program code for receiving an archivefile, which does not include class files, during a class loadingprocess; computer usable program code for searching the archive file todetermine if the archive file contains a particular file that includes adistinctive pattern, wherein the distinctive pattern indicates that theparticular file is a class proxy file, wherein the class proxy fileincludes a locator that points to a location that includes a set ofmodified class data, and further wherein the set of modified class dataincludes a set of bytecodes that have been modified from an architectedindependent language to be executable on a particular Java virtualmachine hosted on a particular architecture, and still further whereinthe class proxy file does not include a class file; and computer usableprogram code for, responsive to locating the particular file, the classproxy file, and the locator, providing the virtual machine access to theset of modified class data.
 10. The computer program product of claim 9further comprising: computer usable program code for, responsive to adetermination that the archive file does not contain a distinctivepattern, determining if the archive file contains a class formatvalidator indicating a presence of a particular class file; and computerusable program code for, responsive to a determination that the archivefile contains a class format validator, translating the particular classfile into a second set of modified class data.
 11. The computer programproduct of claim 9 wherein the set of modified class data comprises aset of modified bytecodes and a modified metadata.
 12. The computerprogram product of claim 9, further comprising: computer usable programcode for including, in the archive file, a plurality of different classproxy files, wherein the plurality of different class proxy filesincludes the class proxy file; and computer usable program code forsearching each one of the plurality of different class proxy files todetermine whether a particular distinctive pattern is located in one ofthe plurality of different class proxy files.
 13. The computer programproduct of claim 9, wherein the computer usable program code forproviding the virtual machine access to the set of modified class datafurther comprises computer usable program code for obtaining the set ofmodified class data, and further wherein the set of modified class dataand a set of values is a static internal representation.
 14. Thecomputer program product of claim 13, further comprising: computerusable program code for creating a dynamic internal representation usingthe set of modified class data is used, wherein translation of classfiles is skipped during the class loading process.
 15. The computerprogram product of claim 9, wherein the distinctive pattern is a fileidentifier that is stored in a particular location in the class proxyfile.
 16. The computer program product of claim 9, wherein the locatoris a data file name that identifies a data file in which the modifiedclass data is stored, and further wherein the data file is stored in afile system and is not stored in the archive file.